package com.kakaxi.mybilibili.adapter;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kakaxi.mybilibili.R;
import com.kakaxi.mybilibili.bean.CategoryHomeItemBean;
import com.kakaxi.mybilibili.utils.DensityUtil;

import java.util.List;

import static com.kakaxi.mybilibili.R.layout.item_recy_categroy_home_content;

/**
 * 分区首页列表适配器
 * Created by kakaxi on 16/10/26.
 */

public class CategoryHomeRecyAdapter extends BaseQuickAdapter<CategoryHomeItemBean,
        BaseViewHolder> {


    public CategoryHomeRecyAdapter(List<CategoryHomeItemBean> data) {
        super(item_recy_categroy_home_content, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, CategoryHomeItemBean
            categoryHomeItemBean) {
        TextView itemView = (TextView) baseViewHolder.itemView.findViewById(R.id
                .txt_category_content);
        itemView.setText(categoryHomeItemBean.getTypename());
        if (categoryHomeItemBean.getTypename().equals("游戏中心")) {
            int right = DensityUtil.dipToPx(mContext, 40);
            int bottom = DensityUtil.dipToPx(mContext, 30);
            categoryHomeItemBean.getCover().setBounds(0, 0, right, bottom);
        } else {
            int num = DensityUtil.dipToPx(mContext, 40);
            categoryHomeItemBean.getCover().setBounds(0, 0, num, num);
        }
        itemView.setCompoundDrawables(null, categoryHomeItemBean.getCover(), null, null);
    }
}
